//
//  HomeDiseaseController.m
//  KYProject
//
//  Created by Roman on 16/12/22.
//  Copyright © 2016年 Roman. All rights reserved.
//

#import "HomeDiseaseController.h"
#import "ChooseDiseaseTypeView.h"
#import "TreatmentModalityController.h"
#import "DiseaseOnSetController.h"
#import "DiseaseDetailController.h"
#import "DiseaseOnSetController.h"
#import "DoctorApplyController.h"

@interface HomeDiseaseController ()

//接口数据纠正
@property (nonatomic, assign) NSInteger newNum;

@property (nonatomic, weak) ChooseDiseaseTypeView *ChooseDiseaseTypeView;

@end

@implementation HomeDiseaseController



- (void)viewDidLoad {
    
    
    [super viewDidLoad];
     
    
    
    self.navigationItem.title = @"疾病详情选择";
    
    ChooseDiseaseTypeView *choose = [ChooseDiseaseTypeView chooseDiseaseView];
    //对类型进行赋值
    choose.lb_DiseaseType.text = self.diseasetypes;
    choose.frame = self.view.bounds;
    
    [self.view addSubview:choose];
    
    
    //关联
    self.ChooseDiseaseTypeView = choose;
    
    //block传值
    [self getBlock];
    
    [self getNotification];
}


- (void)getBlock
{
    
    //治疗
    __weak HomeDiseaseController *weakVC = self;
    self.ChooseDiseaseTypeView.TreatmentModalityBlock = ^()
    {
        TreatmentModalityController *treatmentVC = [[TreatmentModalityController alloc]init];
        
        [weakVC.navigationController pushViewController:treatmentVC animated:YES];
        
    };
    
    //并发症
    self.ChooseDiseaseTypeView.DiseaseOnSetBlock = ^()
    {
        DiseaseOnSetController *DiseaseOnSetVC = [[DiseaseOnSetController alloc]init];
        //在主控制器中获取取得的数据,传递给并发症.
        DiseaseOnSetVC.dataNumber = self.num;
        
        [weakVC.navigationController pushViewController:DiseaseOnSetVC animated:YES];
        
    };
    
    //疾病细分
    self.ChooseDiseaseTypeView.DiseaseDetailBlock = ^()
    {
        DiseaseDetailController *DiseaseDetailVC = [[DiseaseDetailController alloc]init];
        
        [weakVC.navigationController pushViewController:DiseaseDetailVC animated:YES];
        
    };
    
    
    
    
}


- (void)getNotification
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(TreatmentModality:) name:@"Treatment" object:nil];
    
    //并发症选择通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickcomplicationChoose:) name:@"DiseaseOnSet" object:nil];
    
    //疾病细分通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickDiseaseSubdivision:) name:@"DiseaseDetail" object:nil];
    
    //跳转到名医通申请界面
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ApplicationBtn:) name:@"ApplicationBtn" object:nil];
}

#pragma mark
#pragma mark - 通知的实现
//治疗方式
- (void)TreatmentModality:(NSNotification *)sender
{
    //  NSLog(@"%@",sender.object);
    UITableViewCell *cell = sender.object;
    self.ChooseDiseaseTypeView.lb_TreatmentModality.text = cell.textLabel.text;
    self.ChooseDiseaseTypeView.lb_TreatmentModality.textColor = [UIColor blackColor];
}


//并发症选择
-(void)clickcomplicationChoose:(NSNotification *)sender{
    NSMutableArray *array = sender.object;
    self.ChooseDiseaseTypeView.lb_DiseaseOnSet.textColor = [UIColor blackColor];
    
    NSMutableString *MStr = [NSMutableString string];
    for (NSString *str in array) {
        MStr = [MStr stringByAppendingFormat:@" %@",str].mutableCopy;
    }
    //    NSLog(@"%@",MStr);
    if (array.count) {
        self.ChooseDiseaseTypeView.lb_DiseaseOnSet.text = MStr;
    }else{
        self.ChooseDiseaseTypeView.lb_DiseaseOnSet.textColor = [UIColor lightGrayColor];
    }
    
}

//疾病细分选择
-(void)clickDiseaseSubdivision:(NSNotification *)sender{
    NSString *str = sender.object;
    self.ChooseDiseaseTypeView.lb_DiseaseDetail.text = str;
    self.ChooseDiseaseTypeView.lb_DiseaseDetail.textColor = [UIColor blackColor];
}

//申请的跳转.
- (void)ApplicationBtn:(NSNotification *)sender
{
    DoctorApplyController *doctorVC = [[DoctorApplyController alloc]init];
    [self.navigationController pushViewController:doctorVC animated:YES];
    
}
//移除通知
-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    
}



@end
